MODE_ACTORSEQUENCE = {}
MODE_ACTORSEQUENCE.PrevNode = null
MODE_ACTORSEQUENCE.CurrentName = ""

function MODE_ACTORSEQUENCE:Think(player, trace)

end

function MODE_ACTORSEQUENCE:LeftClick(player, trace)
	if trace.HitWorld then

		local entity = ents.Create( "actor_sequence" )
		if(entity and entity:IsValid()) then
		
			entity:PhysicsInit(SOLID_VPHYSICS)
			entity:SetMoveType(MOVETYPE_VPHYSICS)
			entity:SetPos(trace.HitPos + trace.HitNormal)				

			entity:Spawn()
			entity.BaseClass.SetName(entity, MODE_ACTORSEQUENCE.CurrentName)
			entity:InitalizeChain(MODE_ACTORSEQUENCE.PrevNode)

			MODE_ACTORSEQUENCE.PrevNode = entity
				  
			local physicsObject = entity:GetPhysicsObject()
			if physicsObject and physicsObject:IsValid() then
				physicsObject:Wake()
			end
		end
	end
end

function MODE_ACTORSEQUENCE:RightClick(player, trace)
	
end

//----------------------------------------------------------

MODE_SEQUENCEGATHERACTORS = {}
MODE_SEQUENCEGATHERACTORS.TargetWaypoint = nil
MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC = nil
MODE_SEQUENCEGATHERACTORS.GlowEntity = nil



function MODE_SEQUENCEGATHERACTORS:Think(player, trace)

	if CLIENT then
		return
	end

	if MODE_SEQUENCEGATHERACTORS.GlowEntity == nil then

	    local glow = ents.Create("env_lightglow")  
		glow:SetKeyValue("targetname", "idk")  
		glow:SetKeyValue("MinDist", "10")  
		glow:SetKeyValue("MaxDist", "11")  
		glow:SetKeyValue("rendercolor", "200 255 255")  
		glow:SetKeyValue("VerticalGlowSize", "35")  
		glow:SetKeyValue("HorizontalGlowSize", "20")  
		glow:SetKeyValue("GlowProxySize", "10")  
		glow:Spawn()  

		MODE_SEQUENCEGATHERACTORS.GlowEntity = glow;

	end

	if trace.HitNonWorld and trace.Entity:IsNPC() and not trace.Entity:IsPlayer() then
		if MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC == trace.Entity then

			MODE_SEQUENCEGATHERACTORS.GlowEntity:SetPos(trace.HitPos) 

		else
			if MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC then
			end

			MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC = trace.Entity
			MODE_SEQUENCEGATHERACTORS.GlowEntity:SetParent(trace.Entity) 
			
		end
	else
		if MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC then				
			MODE_SEQUENCEGATHERACTORS.LastMouseOverNPC = nil
			MODE_SEQUENCEGATHERACTORS.GlowEntity:SetPos(Vector(0,0,-100));
		end
	end
end

function MODE_SEQUENCEGATHERACTORS:LeftClick(player, trace)
	if trace.HitNonWorld then

		local actor = trace.Entity

		if actor:IsNPC() and not actor:IsPlayer() then
			local waypoint = MODE_SEQUENCEGATHERACTORS.TargetWaypoint
			waypoint:AssignActor(actor)

			datastream.Send( player, "SyncCLSequenceActors", {RecipientEntIdx = waypoint:EntIndex(), NewActorEntIdx = actor:EntIndex()} ,nil)
		end
	end
end

function MODE_SEQUENCEGATHERACTORS:RightClick(player, trace)
	
end

//----------------------------------------------------------

